package com.jiguang.shangcheng.servlet;

import com.jiguang.shangcheng.dao.AdminDao;
import com.jiguang.shangcheng.pojo.Product;
import com.jiguang.shangcheng.pojo.User;
import com.jiguang.shangcheng.utils.MD5;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/admin/admin_selectProduct")
public class adminSelectProduct extends HttpServlet {
    @SneakyThrows
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置字符集
        resp.setContentType("text/html;charset=utf-8");
        req.setCharacterEncoding("UTF-8");

        //获取信息
        String id = req.getParameter("id");
        String cp = req.getParameter("cp");

        //通过id查询该用户的信息
        AdminDao adminDao = new AdminDao();
        Product product = adminDao.selectProductByid(Integer.parseInt(id));

        req.setAttribute("p",product);
        req.setAttribute("cp",cp);

        req.getRequestDispatcher("admin_insertProduct.jsp").forward(req,resp);
    }
}
